<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>课程种类设置</title>
	<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"
		name="viewport">
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/bossIndex.css">
	<link rel="stylesheet" href="css/flexible.css">
	<link rel="stylesheet" href="css/vant.css">
	<script src="js/vue/vue.js"></script>
	<script src="js/vue/axios.js"></script>
	<script src="js/vue/vant.js"></script>
	<script src="js/vue/MD5.js"></script>
	<script src="js/vue/qs.js"></script>
	<script src="js/jquery-3.3.1.min.js"></script>
	<script src="js/fontsize.js"></script>
</head>

<body>
<div id="app">
	<template>
		<div class="Kctype">
			<ul class="clearfix">
				<li v-for="(item,index) in tc" @click="tarIndex(index)"><span :class="{activeType:currIndex==index}">{{item.text}}</span></li>
			</ul>
		</div>
		<div class="hengxian3"></div>
		<div class="margintop60">
			<div class="kczl" v-for="item in dataList" :key="item.id">
				<div class="group_details group_details_state clearfix">
					<div class="fl">
						<img style="border-radius: 50%;" :src="item.Picurl" alt="" class="spinning_img">
					</div>
					<div class="spinning_txt fl" style="padding-top:0;width: 65%;">
						<p><span class="spinning_txx">{{item.Title}}</span><span class="spinning_name">{{item.Sname}}</span></p>
						<p style="margin-top: .1rem;" class="degree">更新时间<span class="many_full">{{item.Addtime}}</span></p>
					</div>
					<div class="TkzlTime fr">
						<div>{{item.Chour}} min</div>
					</div>
				</div>
			</div>
		</div>
	</template>
	<van-list
		v-model="loading"
		:finished="finished"
		finished-text="没有更多了"
		@load="getList"
		>
		<van-cell
			v-for="item in lists"
			:key="item"
			:title="item"
		/>
	</van-list>
	<div class="addType">
		<button type="button" @click="submitData()">课程添加</button>
	</div>
</div>
<script>
	var app = new Vue({
		el: '#app',
		data: {
			tc:[
				{text:"团课"},
				{text:"私教"}
			],
			currIndex:'0',
			dataList:[],
			lists:[],
			loading: false,
			finished: false,
			totalnum:'',
			totalpage:'',
			listd:[],
			page:'1'
		},
		methods: {
			tarIndex(index){
				this.currIndex=index
				this.dataList=[]
				this.lists=[]
				this.listd=[]
				this.page='1'
				this.getList()
			},
			getList(){
				const params={
					page:this.page
				}
				let url="/mobileapi/boss/curriculum_type.php?act=typeList"
				if(this.currIndex=='0'){
					url="/mobileapi/boss/curriculum_type.php?act=typeList"
				}else{
					url="/mobileapi/boss/curriculum_type.php?act=typeListP"
				}
				axios.get(url,{params:params}).then(res => {
					let { msg, code} = res.data
					if (code !== 200) {
						vant.Toast('请求发送失败，请重试')
					} else {
						data=res.data
						this.listd=data.data.list
						this.totalnum=data.data.totalnum
						this.page=parseInt(data.data.page)+1
						for(let i in this.listd){
							if(this.listd[i].Picurl==""||this.listd[i].Picurl==null){
								this.listd[i].Picurl='images/moren.png'
							}
						}
						for (let i = 0; i < this.listd.length; i++) {
							this.dataList.push(this.listd[i])
						}
						// 加载状态结束
						this.loading = false
						// 数据全部加载完成
						if (this.dataList.length >= this.totalnum) {
							this.finished = true
						}
					}
				}).catch(err => {
					vant.Toast('请求发送失败，请重试')
				})
			},
			//跳转到添加课程种类页面
			submitData(){
				if(this.currIndex=='0'){
					window.location.href='addTypeTk.html'
				}else{
					window.location.href='addTypeSk.html'
				}
			}
		}
		
	})
</script>
</body>
</html>